package com.shenmazong.servereduschool.controller;


import com.github.pagehelper.PageInfo;
import com.shenmazong.servereduschool.pojo.TbCollage;
import com.shenmazong.servereduschool.service.ITbCollageService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学院
 * kxt
 */
@RestController
@RequestMapping("/collage")
public class TbCollageController {
    @Autowired
    private ITbCollageService collageService;

    /**
     * 学院注册
     * @param collage
     * @return
     */
    @PostMapping("/registerCollage")
    public ResultResponse registerCollage(@RequestBody TbCollage collage){
        return collageService.registerCollage(collage);
    }

    /**
     * 学院删除
     * @param tbCollage
     * @return
     */
    @PostMapping("/deleteCollage")
    public ResultResponse deleteCollage(@RequestBody TbCollage tbCollage){
        return collageService.deleteCollage(tbCollage);
    }

    /**
     * 学院修改
     * @param collage
     * @return
     */
    @PostMapping("/updateCollage")
    public ResultResponse updateCollage(@RequestBody TbCollage collage){
        return collageService.updateCollage(collage);
    }


    /**
     *
     * @param listParamVo
     * @return
     */
    @PostMapping("/list")
    public ResultResponse findCollageList(@RequestBody ListParamVo listParamVo){
        Integer current = listParamVo.getCurrent();
        Integer size = listParamVo.getSize();
        Object tbCollage = listParamVo.getParamMap().get("tbCollage");
        PageInfo pageInfo=collageService.findCollageList(current, size,tbCollage);
        return ResultResponse.SUCCESS(pageInfo);
    }

    /**
     * 根据编号回显
     * @param
     * @return
     */
    @PostMapping("/queryByCollageId")
    public ResultResponse queryByCollageId(@RequestBody TbCollage tbCollage){
        return collageService.queryByCollageId(tbCollage);
    }

    /**
     * 学院批量删除
     * @param ids
     * @return
     */
    @PostMapping("/del")
    public ResultResponse delAll(@RequestBody List<TbCollage> ids){
        return collageService.deleteAll(ids);
    }

    /**
     * 学院
     * @return
     */
    @PostMapping("/findCollage")
    public ResultResponse findCollage(){
        return collageService.findCollage();
    }

}
